home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok77.lha
/
GadToolsSupport
/
GadToolsSupportTest.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
11KB
|
251 lines
(****************************************************************************
:Program. GadToolsSupportTest.mod
:Contents. TestModule for Gadgets [gvm]
:Author. Richard Günther [gvm]
:Address. HeilbronnerStr.267, 7410 Reutlingen
:Phone. 07121/66432
:Copyright. Public Domain
:Language. Oberon
:Translator. AmigaOberon v2.14d
:History. V1.0 [gvm] 15-May-92 first implementation
:History. V1.1 [gvm] 07-July-92 added menus
:Imports. GadToolsSupport [gvm]
:Bugs. OS2.0 required (isn't really a bug, is it?)
****************************************************************************)
MODULE GadToolsSupportTest ;
IMPORT S : SYSTEM,
I : Intuition,
GT: GadTools,
GS: GadToolsSupport,
G : Graphics,
U : Utility,
E : Exec,
NoGuruRq ;
CONST mxLabels = GS.labels4(S.ADR("show libs"),
S.ADR("show devices"),
S.ADR("show resources"),
S.ADR("show ports"),NIL) ;
CONST cyLabels = GS.labels4(S.ADR("grey"),
S.ADR("black"),
S.ADR("white"),
S.ADR("blue"),NIL) ;
VAR w : I.WindowPtr ;
s : I.ScreenPtr ;
iMsg : I.IntuiMessagePtr ;
win : GS.WinPtr ;
g : I.GadgetPtr ;
quit : BOOLEAN ;
lv,mx : I.GadgetPtr ; (* used for listView Gadget and mx Gadget *)
lvLabels : E.ListPtr ;
nm : I.GadgetPtr ; (* number Gadget *)
tx : I.GadgetPtr ; (* text Gadget *)
cy,pa : I.GadgetPtr ; (* cycle and palette Gadget *)
cb : I.GadgetPtr ; (* checkBox Gadget *)
sc,sl : I.GadgetPtr ; (* scroller and slider Gadget *)
checked : BOOLEAN ;
code,num : INTEGER ;
PROCEDURE OpenAll ;
BEGIN
w:=I.OpenWindowTagsA(NIL,I.waLeft,60,I.waTop,20,I.waWidth,550,I.waHeight,210,
I.waIDCMP,S.VAL(LONGINT,GS.allIDCMP+
LONGSET{I.vanillaKey,I.closeWindow,I.refreshWindow,I.menuPick}),
I.waDragBar,-1,I.waCloseGadget,-1,I.waDepthGadget,-1,
I.waActivate,-1,
I.waTitle,S.ADR("Demo of using Gadgets and Menus with GadToolsSupport"),
I.waMouseQueue,1,I.waSimpleRefresh,-1,
U.done) ;
IF NOT GS.Init(win,s,w) THEN HALT(20) END ;
GS.WaitForDo(win) ;
GS.NewGadget(win,225,190,100,15,"_QUIT",GS.center,100) ;
g:=GS.CreateGadget(win,GT.buttonKind,GT.underscore,GS.uChar,U.done) ;
GS.NewGadget(win,130,20,100,12,"TextKind",GS.left,1) ;
tx:=GS.CreateGadget(win,GT.textKind,GT.txText,S.ADR("Example"),
GT.txBorder,-1,U.done) ;
GS.NewGadget(win,130,40,100,12,"NumberKind",GS.left,2) ;
nm:=GS.CreateGadget(win,GT.numberKind,GT.nmNumber,0,GT.nmBorder,-1,U.done) ;
GS.NewGadget(win,130,60,100,12,"CycleKind",GS.left,3) ;
cy:=GS.CreateGadget(win,GT.cycleKind,GT.cyLabels,S.ADR(cyLabels),
GT.cyActive,1,U.done) ;
(* slLevelFormat : %[-][minWidth][.maxWidth]type
type : ld=decimal ;=lx hex ; lc=character *)
GS.NewGadget(win,130,80,100,12,"SliderKind",GS.left,4) ;
sl:=GS.CreateGadget(win,GT.sliderKind,GT.slMin,0,GT.slMax,255,
GT.slLevel,0,GT.slMaxLevelLen,20,
GT.slLevelFormat,S.ADR("No %-3ld"),
GT.slLevelPlace,S.VAL(LONGINT,GS.right),
U.done) ;
GS.NewGadget(win,130,100,100,12,"ButtonKind",GS.center,10) ;
g:=GS.CreateGadget(win,GT.buttonKind,U.done) ;
(* if readonly then showselected and selected make no sense, if not, *)
(* showselected must contain a stringgadget (for modifying) or NIL (show only) *)
lvLabels:=S.ADR(E.exec.libList) ;
GS.NewGadget(win,30,130,200,50,"ListViewKind",GS.above+GS.highlight,6) ;
lv:=GS.CreateGadget(win,GT.listViewKind,GT.lvTop,0,
GT.lvLabels,lvLabels,
GT.lvReadOnly,-1,
GT.lvScrollWidth,15,
U.done) ;
GS.NewGadget(win,320,20,100,12,"StringKind",GS.right,12) ;
g:=GS.CreateGadget(win,GT.stringKind,GT.stString,S.ADR("Example"),
GT.stMaxChars,32,U.done) ;
GS.NewGadget(win,320,40,100,12,"IntegerKind",GS.right,13) ;
g:=GS.CreateGadget(win,GT.integerKind,GT.inNumber,0,
GT.inMaxChars,10,U.done) ;
GS.NewGadget(win,320,60,120,12,"PaletteKind",GS.right,14) ;
pa:=GS.CreateGadget(win,GT.paletteKind,GT.paDepth,2,
GT.paColor,1,
GT.paColorOffset,0,
GT.paIndicatorWidth,24,
U.done) ;
GS.NewGadget(win,320,80,112,12,"ScrollerKind",GS.right,5) ;
sc:=GS.CreateGadget(win,GT.scrollerKind,GT.scTop,0,
GT.scTotal,259,
GT.scVisible,4,
GT.scArrows,18,U.done) ;
checked:=TRUE ;
GS.NewGadget(win,320,100,100,12,"CheckboxKind",GS.right,11) ;
cb:=GS.CreateGadget(win,GT.checkBoxKind,GT.cbChecked,-1,U.done) ;
(* text is ignored, textpos is textpos of mx-items ! *)
GS.NewGadget(win,320,131,250,50,"",GS.right,15) ;
mx:=GS.CreateGadget(win,GT.mxKind,GT.mxLabels,S.ADR(mxLabels),
GT.mxActive,0,
GT.mxSpacing,3,
U.done) ;
GS.Do(win) ;
GS.BeginMenus(win) ;
GS.MenuTitle(win,"Project",TRUE) ;
GS.MenuItem(win,"About","",{}) ;
GS.MenuSubItem(win,"GadgetTest (c) 1992 by","",{},GS.none) ;
GS.MenuSubItem(win," Richard Günther","",{},GS.none) ;
GS.MenuItem(win,"QUIT","q",{}) ;
GS.MenuTitle(win,"Gadgets",TRUE) ;
GS.MenuItem(win,"Colors","",{}) ;
GS.MenuSubItem(win,"grey","",{},GS.none) ;
GS.MenuSubItem(win,"black","",{},GS.none) ;
GS.MenuSubItem(win,"white","",{},GS.none) ;
GS.MenuSubItem(win,"blue","",{},GS.none) ;
GS.MenuItem(win,"Show","",{}) ;
GS.MenuSubItem(win,"libs","",{},GS.none) ;
GS.MenuSubItem(win,"devices","",{},GS.none) ;
GS.MenuSubItem(win,"resources","",{},GS.none) ;
GS.MenuSubItem(win,"ports","",{},GS.none) ;
GS.MenuItem(win,"Checkbox","",{}) ;
GS.MenuSubItem(win,"set","",{},GS.none) ;
GS.MenuSubItem(win,"clear","",{},GS.none) ;
IF ~GS.DoMenus(win,0) THEN HALT(20) END ;
END OpenAll ;
BEGIN
OpenAll ;
quit:=FALSE ;
REPEAT
E.WaitPort(w.userPort) ;
iMsg:=GT.GetIMsg(w.userPort) ;
WHILE iMsg#NIL DO
IF I.refreshWindow IN iMsg.class THEN
GT.BeginRefresh(w) ; GT.EndRefresh(w,I.LTRUE) ;
ELSIF I.menuPick IN iMsg.class THEN
code:=iMsg.code ;
WHILE code#I.menuNull DO
CASE I.MenuNum(code) OF
0: IF I.ItemNum(code)=1 THEN quit:=TRUE END ;
| 1: CASE I.ItemNum(code) OF
0: num:=I.SubNum(code) ;
IF num#I.menuNull THEN
GS.SetGadgetAttrs(win,pa,GT.paColor,num,U.done) ;
GS.SetGadgetAttrs(win,cy,GT.cyActive,num,U.done) ;
END ;
| 1: num:=I.SubNum(code) ;
CASE num OF
0 : lvLabels:=S.ADR(E.exec.libList)
| 1 : lvLabels:=S.ADR(E.exec.deviceList)
| 2 : lvLabels:=S.ADR(E.exec.resourceList)
| 3 : lvLabels:=S.ADR(E.exec.portList) ;
END ;
GS.SetGadgetAttrs(win,lv,GT.lvLabels,lvLabels,
GT.lvTop,0,U.done) ;
GS.SetGadgetAttrs(win,mx,GT.mxActive,num,U.done) ;
| 2: IF I.SubNum(code)=0 THEN checked:=TRUE ;
ELSE checked:=FALSE ;
END ;
GS.SetGadgetAttrs(win,cb,GT.cbChecked,S.VAL(SHORTINT,checked),U.done) ;
END ;
END ;
code:=GS.NextSelected(win,code) ;
END ;
ELSIF I.gadgetUp IN iMsg.class THEN
g:=iMsg.iAddress ;
CASE g.gadgetID OF
100: quit:=TRUE ; (* QUIT *)
| 13: (* integer (connected with number) *)
GS.SetGadgetAttrs(win,nm,GT.nmNumber,g.specialInfo(I.StringInfo).longInt,
U.done) ;
| 12: (* string (connected with text) *)
GS.SetGadgetAttrs(win,tx,GT.txText,g.specialInfo(I.StringInfo).buffer,
U.done) ;
| 3: (* cycle (connected with palette) *)
GS.SetGadgetAttrs(win,pa,GT.paColor,iMsg.code,U.done) ;
| 14: (* palette (connected with cycle) *)
GS.SetGadgetAttrs(win,cy,GT.cyActive,iMsg.code,U.done) ;
| 11: checked:=~checked ; (* checkbox (connected with button) *)
| 10: checked:=~checked ; (* button (connected with checkbox) *)
GS.SetGadgetAttrs(win,cb,GT.cbChecked,S.VAL(SHORTINT,checked),U.done) ;
ELSE I.DisplayBeep(s)
END ;
ELSIF I.gadgetDown IN iMsg.class THEN
g:=iMsg.iAddress ;
IF g.gadgetID=15 THEN
CASE iMsg.code OF
0 : lvLabels:=S.ADR(E.exec.libList)
| 1 : lvLabels:=S.ADR(E.exec.deviceList)
| 2 : lvLabels:=S.ADR(E.exec.resourceList)
| 3 : lvLabels:=S.ADR(E.exec.portList) ;
END ;
GS.SetGadgetAttrs(win,lv,GT.lvLabels,lvLabels,
GT.lvTop,0,U.done) ;
ELSE I.DisplayBeep(s)
END ;
ELSIF I.mouseMove IN iMsg.class THEN
g:=iMsg.iAddress ;
IF g.gadgetID=4 THEN (* slider *)
GS.SetGadgetAttrs(win,sc,GT.scTop,iMsg.code,U.done) ;
ELSIF g.gadgetID=5 THEN (* scroller *)
GS.SetGadgetAttrs(win,sl,GT.slLevel,iMsg.code,U.done) ;
END ;
ELSIF I.vanillaKey IN iMsg.class THEN
IF iMsg.code=ORD("Q") THEN quit:=TRUE END ; (* Q - Key *)
ELSIF I.closeWindow IN iMsg.class THEN quit:=TRUE ;
END ;
GT.ReplyIMsg(iMsg) ;
iMsg:=GT.GetIMsg(w.userPort) ;
END ;
UNTIL quit ;
CLOSE
IF w#NIL THEN I.CloseWindow(w) END ;
IF (win#NIL) THEN GS.Dispose(win) END ;
END GadToolsSupportTest.